package springdao.model;

import java.io.Serializable;
import javax.jdo.identity.LongIdentity;
import javax.jdo.identity.IntIdentity;

/**
 *
 * @author Kent
 */
public class UserStorePK implements Serializable {

    private static final long serialVersionUID = 1794742527018289345L;
    public LongIdentity owner;
    public IntIdentity storage;
    public String goods;

    public UserStorePK() {
    }

    public UserStorePK(long ownerId, int soreageId, String goods) {
        this.owner = new LongIdentity(Member.class, ownerId);
        this.storage = new IntIdentity(Storage.class, soreageId);
        this.goods = goods;
    }

    public UserStorePK(Member owner, Storage storage, String goods) {
        this(owner.getId(), storage.getSid(), goods);
    }

    public String getGoods() {
        return goods;
    }

    public void setGoods(String goods) {
        this.goods = goods;
    }

    public long getOwner() {
        return owner.getKey();
    }

    public void setOwner(long owner) {
        this.owner = new LongIdentity(Member.class, owner);
    }

    public int getStorage() {
        return storage.getKey();
    }

    public void setStorage(int storage) {
        this.storage = new IntIdentity(Storage.class, storage);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final UserStorePK other = (UserStorePK) obj;
        if (this.owner != other.owner && (this.owner == null || !this.owner.equals(other.owner))) {
            return false;
        }
        if (this.storage != other.storage && (this.storage == null || !this.storage.equals(other.storage))) {
            return false;
        }
        if ((this.goods == null) ? (other.goods != null) : !this.goods.equals(other.goods)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 79 * hash + (this.owner != null ? this.owner.hashCode() : 0);
        hash = 79 * hash + (this.storage != null ? this.storage.hashCode() : 0);
        hash = 79 * hash + (this.goods != null ? this.goods.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "springdao.model.UserstorePK[ id=" + owner + ", sid=" + storage + ", goods=" + goods + " ]";
    }
}
